Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[최단경로] 11월 29일 #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

[최단경로] 11월 29일 #15

wants to merge 5 commits into from

Conversation

sooooscode
Copy link
Collaborator

###과제제출
기존제출:
15685.cpp
1238.cpp
2458.cpp

Copy link

@Dong-droid Dong-droid Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3.코드리뷰완료

안녕하세요, 김연수님. 수고하셨습니다!


auto dijkstra = [&](int start)
{
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
Copy link

@Dong-droid Dong-droid Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3. pair<int,int>를 typedef을 사용해서 짧게 사용하면 어떨까요?

int now = pq.top().second;
pq.pop();

if (distance[now] < dist) continue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 최적화에 중요합니다. 잘하셨네요!

Comment on lines +28 to +37
for (int k = 1; k <= n; ++k)
{
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= n; ++j)
{
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3. 모듈화를 하면 좋을 것 같습니다.

Comment on lines +40 to +54

for (int i = 1; i <= n; ++i)
{
int cnt = 0;

for (int j = 1; j <= n; ++j)
{
if (dist[i][j] != INF || dist[j][i] != INF) {
cnt++;
}
}

if (cnt == n - 1) ans++;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3. 여기도요! 잘 푸셨네요~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants